/**
 * Author: Dmitry Ustimov
 * Date: 5/14/13
 * Time: 10:04 AM
 */

package com.gmail.dmitryustimov.ms.java7.chain_of_responsibility.mod.example;

public abstract class LoggerHandler<T extends LogMessage> extends Handler<T> {

    protected LogLevel loggerLevel;

    public LoggerHandler(LogLevel loggerLevel) {
        this.loggerLevel = loggerLevel;
    }

    @Override
    public Boolean canHandle(T request) {
        return request.getLogLevel().compareTo(loggerLevel) >= 0;
    }

    @Override
    public void doAction(T request) {
        writeMessage(request.getMessage());
    }

    protected abstract void writeMessage(String msg);
}
